<template>
  <div>
    <table class="my-table">
      <thead>
        <slot></slot>
      </thead>
      <tbody>
        <tr v-for="item in records" :key="item.id">
          <td>{{ item.date }}</td>
          <td>{{ item.doctor }}</td>
          <td>{{ item.diagnosis }}</td>
          <td>{{ item.prescription }}</td>
          <td @click="$emit('appear', item.id)">详情</td>
        </tr>
      </tbody>
    </table>
  </div>
</template>

<script>
export default {
  props: ['records']
}
</script>

<style>
.my-table {
  border-collapse: collapse;
  width: 100%;
}

.my-table td,
.my-table th {
  border: 1px solid #ddd;
  padding: 8px;
  text-align: left;
}

.my-table th {
  background-color: #f2f2f2;
}
</style>
